//
//  ConsumerParentController.m
//  XiaoMiao
//
//  Created by kinglian_iOS_000 on 2018/1/22.
//  Copyright © 2018年 smallyou. All rights reserved.
//

#import "ConsumerParentController.h"
#import "XiaoMiao-Swift.h"
#import "ConsumerListController.h"
#import "XMCameraTimeAndAngleViewController.h"

@interface ConsumerParentController () {
    ConsumerParentVCType VCType_;
}

@end

@implementation ConsumerParentController

- (instancetype)initWithVCType:(ConsumerParentVCType)VCType {
    if (self = [super init]) {
        VCType_ = VCType;
    }
    
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupNav];
    
    [self setupPage]; 
}

- (void)setupNav {
    switch (VCType_) {
        case ConsumerParentVCTypeSearch:
            self.title = @"查询";
            break;
            
        case ConsumerParentVCTypeSeletedOld:
            self.title = @"已有客户";
            break;
    }
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem app_createItemImageName:@"ic_common_btn_add_blue" target:self action:@selector(rightBarButtonItemClick)];
    NSMutableDictionary *dictM = [NSMutableDictionary dictionary];
    dictM[NSForegroundColorAttributeName] = kMainBlueColor;
    [self.navigationItem.rightBarButtonItem setTitleTextAttributes:dictM forState:UIControlStateNormal];
}

- (void)setupPage {
    NSArray *titles = @[@"姓名列表", @"项目列表"];
    
    //
    KLPageStyle *style = [[KLPageStyle alloc] init];
    style.titleFont = [UIFont systemFontOfSize:14];
    style.titleH = 44.f; // 标题高度
    style.titleNorColor = HEXPColor(0x2c2e30, 1.0);
    style.titleSelColor = kMainBlueColor;
    style.bottomLineColor = kMainBlueColor;
    
    //
    CGFloat contentH = kScreenHeight - 64 - style.titleH;
    
    ConsumerListController *list1 = [[ConsumerListController alloc] initWithViewHeight:contentH isSearchType:VCType_ == ConsumerParentVCTypeSearch vcType:ConsumerListVCTypeName];
    ConsumerListController *list2 = [[ConsumerListController alloc] initWithViewHeight:contentH isSearchType:VCType_ == ConsumerParentVCTypeSearch vcType:ConsumerListVCTypeProject];
    
    //
    NSArray *childVCs = @[list1, list2];
    
    CGRect fram = CGRectMake(0, 0, kScreenWidth, kScreenHeight - 64);
    KLPageView *pageView = [[KLPageView alloc] initWithFrame:fram titles:titles style:style childVCs:childVCs parentVC:self];
    
    [self.view addSubview:pageView];
}

#pragma mark - Action
- (void)rightBarButtonItemClick {
    XMCameraTimeAndAngleViewController *creat = [[XMCameraTimeAndAngleViewController alloc]init];
    [self.navigationController pushViewController:creat animated:YES];
}

@end
